
package nccloud.web.arap.payablebill.action;

import nc.itf.org.IOrgResourceCodeConst;
import nccloud.framework.web.processor.refgrid.RefQueryInfo;
import nccloud.framework.web.ui.meta.RefMeta;
import nccloud.web.refer.DefaultGridRefAction;

public class PayablebillDefaultGridRefAction extends DefaultGridRefAction {

	public PayablebillDefaultGridRefAction() {
		super();
		setResourceCode(IOrgResourceCodeConst.ORG);
	}

	@Override
	public RefMeta getRefMeta(RefQueryInfo arg0) {
		RefMeta retMeta = new RefMeta();

		retMeta.setCodeField("billno");
		retMeta.setNameField("billdate");
		retMeta.setPkField("pk_payablebill");
		retMeta.setTableName("ap_payablebill");
		retMeta.setExtraFields(new String[] { "billno", "billdate" });
		retMeta.setMutilLangNameRef(false);
		setShowDisabledData(null);
		return retMeta;
	}

	@Override
	public String getOrderSql(RefQueryInfo para, RefMeta meta) {
		return null;
	}

	@Override
	public String getExtraSql(RefQueryInfo para, RefMeta meta) {
		StringBuffer sql = new StringBuffer();
		sql.append(" dr=0 and pk_tradetype='F1-Cxx-QTYT1' and billstatus=1 and pk_payablebill not in( ");
		sql.append(
				" select p1.pk_payablebill from ap_payableitem p1 INNER JOIN ap_payableitem p2 on p2.top_itemid=p1.pk_payableitem ");
		sql.append(
				" where p1.dr=0 and p2.dr=0 and p1.pk_tradetype='F1-Cxx-QTYT1' and p2.pk_tradetype='F1-Cxx-REDQTYT1') ");
		return sql.toString();
	}

}
